package com.loong.game2048.server.impl;

import com.loong.game2048.Exception.BizException;
import com.loong.game2048.dao.GameDao;
import com.loong.game2048.module.Game;
import com.loong.game2048.server.GameService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author lyx
 * @date 2020/5/23 20:36
 */
@Service
public class GameServiceImpl implements GameService {

    @Resource
    private GameDao gameDao;

    @Override
    public List<Game> getAllGame() {
        return gameDao.getAllGame();
    }

    @Override
    public Game addTag(Game game) {
        if (gameDao.getTag(game.getGame())>0){
            throw new BizException("此标签已存在，不可重复添加");
        }
        gameDao.addTag(game);
        return game;
    }
}
